<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script>
    // 18.  数组转对象；    ['a','a','a','b','b','c','c','c','c','d','d','d','d'] 
    var arr = ['a', 'a', 'a', 'b', 'b', 'c', 'c', 'c', 'c', 'd', 'd', 'd', 'd'];
    function obj(arr) {
      var obj = {};
      for (var i = 0; i < arr.length; i++) {
        if (obj[arr[i]]) {
          obj[arr[i]]++;
        } else {
          obj[arr[i]] = 1;
        }
      }
      return obj;
    }
    console.log(obj(arr));
  </script>
</head>
<body>
  
</body>
</html>